package StudyCode.summary.BufferAndChannel;

import java.nio.ByteBuffer;
import java.nio.ByteOrder;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class SettingByteOrderingByteBuffer {
	public static void main(String[] args) {
		ByteBuffer buf = ByteBuffer.allocate(10);

		buf.putShort(0, (short) 123);
		System.out.println("更改顺序前:");
		System.out.println(buf.get(0)); // 0
		System.out.println(buf.get(1)); // 123

		buf.order(ByteOrder.LITTLE_ENDIAN);
		System.out.println("更改顺序后:");
		buf.putShort(0, (short) 123);
		System.out.println(buf.get(0)); // 123
		System.out.println(buf.get(1)); // 0
	}
}
